package com.anthonybennis.blender.client.pages.keyboard;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.googlecode.mgwt.dom.client.event.tap.TapEvent;
import com.googlecode.mgwt.dom.client.event.tap.TapHandler;
import com.googlecode.mgwt.ui.client.widget.touch.TouchPanel;

/**
 * 
 * @author abennis
 */
public class Tile 
{
	private final TileDescriptionPanel _descriptionPanel;
	
	public Tile(TileDescriptionPanel descriptionPanel)
	{
		_descriptionPanel = descriptionPanel;
	}
	
	/**
	 * 
	 * @return
	 */
	protected Widget create(final String[] data)
	{	
		TouchPanel tilePanel = new TouchPanel();
		tilePanel.addTapHandler(new TapHandler() {
			
			@Override
			public void onTap(TapEvent event) {
				_descriptionPanel.showDescription(data[TileDataFactory.SHORT_CUT_INDEX], data[TileDataFactory.FEATURE_NAME_INDEX],data[TileDataFactory.DESCRIPTION_INDEX]);
			}
		});
		
		tilePanel.setStyleName("tile");
		
		Label header = new Label(data[TileDataFactory.FEATURE_NAME_INDEX]);
		header.setStyleName("tile-header-label");
		tilePanel.add(header);
		
		Label shortCutLabel = new Label(data[TileDataFactory.SHORT_CUT_INDEX]);
		shortCutLabel.setStyleName("shortcut-label");
		tilePanel.add(shortCutLabel);
				
		return tilePanel;
	}
}